﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Entity;
using Utils;
using Library;
using DataContext;

namespace PaymentBLL
{
    public class CtrLogPaymentGatewayOut
    {
        public int InsertLogPaymentGatewayOut(int accountId, string accountName, int accountTypeId,
            int paymentGatewayId, string paymentGatewayName, string paymentGatewayUnit,
            string paymentAccountInfo, string systemAccountInfo,int auOut,int agOut,int receiveAmount, int vndOut,
            int status, int? resultCode, string description, ref long? id)
        {
            return DB.PaymentInstance.uspLogPaymentGatewayOutInsert(accountId, accountName, accountTypeId,
                paymentGatewayId, paymentGatewayName, paymentGatewayUnit,
                paymentAccountInfo, systemAccountInfo,auOut,agOut,receiveAmount,vndOut,status,resultCode,description,ref id);
        }

        public int UpdateLogPaymentGatewayOut(long id, int status, int? resultCode, string description)
        {
            if (description == string.Empty)
                description = null;
            return DB.PaymentInstance.uspLogPaymentGatewayOutUpdate(id, status, resultCode, description);
        }

        public List<uspLogPaymentGatewayOutSelectByResult> SelectLogPaymentGatewayOutBy(long id, DateTime fromDate, DateTime toDate,
           int accountId, int accountTypeId, string accountName, int paymentGatewayId, string paymentGatewayName, string paymentGatewayUnit,
           ref int? totalAuOut, ref int? totalAgOut, ref int? totalReceiveVnd,
           int currentPage, int pageSize, ref int? totalRecord)
        {
            return DB.PaymentInstance.uspLogPaymentGatewayOutSelectBy(id, fromDate, toDate, accountId, accountTypeId, accountName,
                paymentGatewayId, paymentGatewayName, paymentGatewayUnit, ref totalAuOut, ref totalAgOut, ref totalReceiveVnd, 
                currentPage, pageSize, ref totalRecord).ToList();
        }

        public uspLogPaymentGatewayOutStatisticsResult StatisticsLogPaymentGatewayOut(DateTime fromDate, DateTime toDate)
        {
            return DB.PaymentInstance.uspLogPaymentGatewayOutStatistics(fromDate, toDate).FirstOrDefault();
        }

        public List<uspLogPaymentGatewayOutSumStatisticsResult> StatisticsLogPaymentGatewayOutSum(long id, DateTime fromDate, DateTime toDate,
           int accountId, int accountTypeId, string accountName)
        {
            return DB.PaymentInstance.uspLogPaymentGatewayOutSumStatistics(id, fromDate, toDate, accountId, accountTypeId, accountName).ToList();
        }
    }
}
